/* eslint-disable prettier/prettier */
import React from 'react';
import { Form } from 'antd';
import { SearchAndSelectC, FirstHeaderC, AdvancedSearch, DATA_ENTRY } from '@/src/components';
import config from '@/src/components/business/searchAndSelect/enum';

class SearchAndSelect extends React.Component {
  constructor(props) {
    super(props);
    this.formRef = React.createRef();
    this.state = {
      initialValue: undefined,
    };
    setTimeout(() => {
      this.setState({
        initialValue: '02',
      });
    }, 0);
  }

  onQuery = (query) => {
    console.log(query, 'query');
  };

  onClear = () => {};

  onChange = (name, code) => {
    this.setState({ name, code });
  };

  render() {
    return (
      <>
      <div style={{width:'700px',marginLeft:'10px'}}>
      <div > 这种是 产品管理，非标准化债权类资产，非标准化债权类投资，资产管理计划维护，理财直融查询页面的证券代码使用，
      且值为id，后端接口并不支持id查询，所以这边没有做初始化赋值 和变更处理</div>
        <Form ref={this.formRef} >
        <FirstHeaderC title='产品管理' />
        <div > 
           <p>使用时 dataIndex 要求为数组 [dataIndex,query参数名] 第一个是表单name，第二个值是模糊查询时 传递给后端的参数名</p>
        </div>
        <SearchAndSelectC
          form={this.formRef.current}
          title='产品管理'
          dataIndex={['productId','productName']}
          codeType={config.cpgl}
          onChange={(name, code) => console.log(name, code)}
        />
        <FirstHeaderC title='资产管理计划维护' />
        <SearchAndSelectC
          form={this.formRef.current}
          title='资产管理计划维护'
          dataIndex={['valueId','value']}
          codeType={config.zcgljh}
          onChange={(name, code) => console.log(name, code)}
        />
        <FirstHeaderC title='理财直融' />
        <SearchAndSelectC
          form={this.formRef.current}
          title='理财直融'
          dataIndex={['search_LIKE_secuid', 'search_LIKE_secucode']}
          codeType={config.lczr}
          onChange={(name, code) => console.log(name, code)}
        />
        
        </Form>
        <FirstHeaderC title='查询组件用应用' />
        <AdvancedSearch
          dataSource={[
            {
              dataIndex: ['valueId1',"value"],
              title: '资产管理计划维护',
              type: DATA_ENTRY.SEARCHANDSELECTC,
              codeType: config.zcgljh,
            },
            {
              dataIndex: 'other',
              title: '其他查询条件',
              type: DATA_ENTRY.SELECT,
              dataSource: [{ value: "name", title: "name" }],
              rules:[{required:true}]
            },
          ]}
          onQuery={this.onQuery}
          onClear={this.onClear}
        />
      </div>
      </>
    );
  }
}

export default SearchAndSelect;
